package com.zzzzzz.core.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class CommonController extends BaseController {

	/**
	 * Handles requests for the application home page.
	 */
	@RequestMapping(value="/", method=RequestMethod.GET)
	public String home(Model model, HttpServletRequest request) {
		model.addAttribute("cur", "home");
		return "home";
	}

	@RequestMapping(value = "/error", method = RequestMethod.GET)
	public String error() {
		return "error";
	}

	@RequestMapping(value="/unauthorized", method=RequestMethod.GET)
	public String unauthorized(Model model, HttpServletRequest request) {
		if(isSignedIn()) {
	        return "redirect:/dashboard";
		}else {
	        return "redirect:/login";
		}
	}
	
}
